package com.mdx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdx.bean.BlightBean;
import com.mdx.dao.BlightDao;
import com.mdx.service.IBlightService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class BlightServiceImpl extends ServiceImpl<BlightDao, BlightBean> implements IBlightService {

    @Resource
    private BlightDao blightDao;

    @Override
    public IPage<BlightBean> findByNameHost(int pageNO, int pageSize, String blightName, String host) {
        IPage<BlightBean> page = new Page<>(pageNO,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if (blightName != null && !blightName.equals("")){
            wrapper.like("f_blightName",blightName);
        }
        if (host != null && !host.equals("")){
            wrapper.like("f_host",host);
        }
        IPage<BlightBean> iPage = this.page(page,wrapper);
        return iPage;
    }
}
